package edu.biwu.response;

import jakarta.servlet.*;
import jakarta.servlet.http.*;
import jakarta.servlet.annotation.*;

import java.io.IOException;
import java.io.PrintWriter;

/**
 * HttpServletResponse操作字符流的方法：
 *    public PrintWriter getWriter() throws IOException:获取一个字符输出流，将来向客户端响应数据（写入响应体，响应给客户端）
 */

@WebServlet("/resp/demo03")
public class ResponseDemo03 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        PrintWriter printWriter = response.getWriter();
        printWriter.write("<font color='red'>demo03</font>");
        printWriter.write("</br>");
        printWriter.write("<font color='blue'>demo03</font>");
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
